﻿using MediatR;
using System.WXT.Infrstructre.Interface;
using System.WXT.WebAPI.Application.Command.CraftCommand;

namespace System.WXT.WebAPI.Application.CommandHandlers.CraftCommandHandlers
{
    public class CraftUpdateCommandHandlers:IRequestHandler<CraftUpdateCommand,int>
    {
        protected readonly ICraftRepository craftRepository;

        public CraftUpdateCommandHandlers(ICraftRepository craftRepository)
        {
            this.craftRepository = craftRepository;
        }
        /// <summary>
        /// 工艺修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<int> Handle(CraftUpdateCommand request, CancellationToken cancellationToken)
        {
            var res = request.craftManageDate.Value.ToUniversalTime();
            var list = await craftRepository.Update(new Domain.Craft { craftManageId = request.craftManageId, craftManagenumbering = request.craftManagenumbering, craftManageName = request.craftManageName, craftManageState = request.craftManageState, craftManageFinishName = request.craftManageFinishName, craftManageDate = res, craftManageAddName = request.craftManageAddName });
            return list;
        }
    }
}
